<?php
require("general_include.php");
$action = $_REQUEST['action'];
if($action == 'populateCity')
{
            $CitySql = "SELECT city_id, city_key FROM ".TABLEPREFIX."_cities WHERE city_name LIKE '".$_POST['data']."%' 
			ORDER BY city_name limit 0,20";
			$CityArr = $UserManagerObjAjax->GetRecords("All",$CitySql);
	
			$dataList = array();
	
			foreach ($CityArr as $row)
			{
				$toReturn   = html_entity_decode(htmlentities($row['city_key']));;
				$dataList[] = '<li id="' .$row['city_id'] . '"><a href="javascript:;" >' . $toReturn . '</a></li>';
			}
			
			if (count($dataList)>=1)
			{
				$dataOutput = join("\r\n", $dataList);
				echo $dataOutput;
			}
			else
			{
				echo '<li><a href="javascript:;">No Results</a></li>';
			}
}
if($action == 'populateCountry')
{
     $adSql = "SELECT country_id FROM ".TABLEPREFIX."_city WHERE city_id='".$_REQUEST['cityid']."'";
	 $adArr = $UserManagerObjAjax->GetRecords("Row",$adSql);
	 
	// $citySql = "SELECT * FROM ".TABLEPREFIX."_city WHERE city_id='".$adArr['add_city_id']."'";
	// $cityArr = $UserManagerObjAjax->GetRecords("Row",$citySql);
	 
	$countrySql = "SELECT country_id,country_name FROM ".TABLEPREFIX."_country ORDER BY country_name";
    $CountryArr = $UserManagerObjAjax->GetRecords("All",$countrySql);
	$str = '<select name="avail_country" id="avail_country" class="drop-down" onchange="avail_submit(this.value)">
			<option value="">Select</option>';
	$NumCoun=count($CountryArr);
	
	for($i=0;$i<$NumCoun;$i++)
	{		
       $sel = $adArr[0] == $CountryArr[$i]['country_id'] ? "selected" : "";
	   $str.='<option value="'.$CountryArr[$i]['country_id'].'" '.$sel.'>'.$CountryArr[$i]['country_name'].'</option>';
    
    }
	$str.='</select>';
	 echo $str;

}
?>